<?php

namespace App\Console\Commands;

use App\Models\User;
use Illuminate\Console\Command;

class GenerateToken extends Command
{
	protected $signature = 'cc:token';

	protected $description = 'Generate lont-term test token directly';

	public function __construct()
	{
		parent::__construct();
	}

	public function handle()
	{
		$userId = $this->ask('Input user id');

		$user = User::find($userId);

		if (!$user) {
			$this->error('Expected user does not exist.');
			return;
		}

		$ttl = 365*24*60; // minutes.
		$this->info(auth('api')->setTTL($ttl)->login($user));
	}
}
